/*  
     PlAr is Platform Arena: a 2D multiplayer shooting game
     Copyright (C) 2009 Ragagnin Antonio <spocchio@gmail.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package plar.core.defaultElements;

import java.awt.Point;

import plar.core.Common;
import plar.core.Element;
import plar.core.Parameters;

public class Gun extends Element {

	int ammo;
	public Player owner;
	String gunName;
	public Gun(Player player) {
		super();
		owner = player;
		ammo = 0;
		gunName = new String("Gun");
	     setProperty("gunName",gunName);
		setProperty("shootSpeed", 10);
	}

public String getGunName()
{
		return (String)getProperty("gunName");
}
public int getAmmo()
{
		return ammo;
}
	public void addAmmo(int i) {
		ammo += i;

	}

	public void fire() {
	
	}

	public Point getShootRelativePosition() {
		Point pos = new Point(owner.getPosition());
		//Double d = (Double) owner.getProperty("shootDirection");
		Double dx = (Double) owner.getProperty("directionx");
		Double dy = (Double) owner.getProperty("directiony");
		
		//if(d<=0.5) d= 0.0; else d=1.0;
		pos.y += owner.getSize().y / 4;
		pos.x += owner.getSize().x / 2;
		pos.x += dx * (owner.getSize().x * 2);
		pos.y += dy * (owner.getSize().y * 2);
		return pos;
	}
}
